3.2 \(\int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx\)

Optimal. Leaf size=24 \[ \frac {1}{3} a \sin ^3(x)+\frac {1}{3} b \cos ^3(x)-b \cos (x) \]

[Out]

-b*cos(x)+1/3*b*cos(x)^3+1/3*a*sin(x)^3

________________________________________________________________________________________

Rubi [A]  time = 0.04, antiderivative size = 24, normalized size of antiderivative = 1.00, number of steps used = 6, number of rules used = 4, integrand size = 14, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3089, 2564, 30, 2633} \[ \frac {1}{3} a \sin ^3(x)+\frac {1}{3} b \cos ^3(x)-b \cos (x) \]

Antiderivative was successfully verified.

[In]

Int[Sin[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

-(b*Cos[x]) + (b*Cos[x]^3)/3 + (a*Sin[x]^3)/3

Rule 30

Int[(x_)^(m_.), x_Symbol] :> Simp[x^(m + 1)/(m + 1), x] /; FreeQ[m, x] && NeQ[m, -1]

Rule 2564

Int[cos[(e_.) + (f_.)*(x_)]^(n_.)*((a_.)*sin[(e_.) + (f_.)*(x_)])^(m_.), x_Symbol] :> Dist[1/(a*f), Subst[Int[
x^m*(1 - x^2/a^2)^((n - 1)/2), x], x, a*Sin[e + f*x]], x] /; FreeQ[{a, e, f, m}, x] && IntegerQ[(n - 1)/2] &&
 !(IntegerQ[(m - 1)/2] && LtQ[0, m, n])

Rule 2633

Int[sin[(c_.) + (d_.)*(x_)]^(n_), x_Symbol] :> -Dist[d^(-1), Subst[Int[Expand[(1 - x^2)^((n - 1)/2), x], x], x
, Cos[c + d*x]], x] /; FreeQ[{c, d}, x] && IGtQ[(n - 1)/2, 0]

Rule 3089

Int[sin[(c_.) + (d_.)*(x_)]^(m_.)*(cos[(c_.) + (d_.)*(x_)]*(a_.) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(n_.), x_Sym
bol] :> Int[ExpandTrig[sin[c + d*x]^m*(a*cos[c + d*x] + b*sin[c + d*x])^n, x], x] /; FreeQ[{a, b, c, d}, x] &&
 IntegerQ[m] && IGtQ[n, 0]

Rubi steps

\begin {align*} \int \sin ^2(x) (a \cos (x)+b \sin (x)) \, dx &=\int \left (a \cos (x) \sin ^2(x)+b \sin ^3(x)\right ) \, dx\\ &=a \int \cos (x) \sin ^2(x) \, dx+b \int \sin ^3(x) \, dx\\ &=a \operatorname {Subst}\left (\int x^2 \, dx,x,\sin (x)\right )-b \operatorname {Subst}\left (\int \left (1-x^2\right ) \, dx,x,\cos (x)\right )\\ &=-b \cos (x)+\frac {1}{3} b \cos ^3(x)+\frac {1}{3} a \sin ^3(x)\\ \end {align*}

________________________________________________________________________________________

Mathematica [A]  time = 0.00, size = 26, normalized size = 1.08 \[ \frac {1}{3} a \sin ^3(x)-\frac {3}{4} b \cos (x)+\frac {1}{12} b \cos (3 x) \]

Antiderivative was successfully verified.

[In]

Integrate[Sin[x]^2*(a*Cos[x] + b*Sin[x]),x]

[Out]

(-3*b*Cos[x])/4 + (b*Cos[3*x])/12 + (a*Sin[x]^3)/3

________________________________________________________________________________________

fricas [A]  time = 0.45, size = 27, normalized size = 1.12 \[ \frac {1}{3} \, b \cos \relax (x)^{3} - b \cos \relax (x) - \frac {1}{3} \, {\left (a \cos \relax (x)^{2} - a\right )} \sin \relax (x) \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="fricas")

[Out]

1/3*b*cos(x)^3 - b*cos(x) - 1/3*(a*cos(x)^2 - a)*sin(x)

________________________________________________________________________________________

giac [A]  time = 2.96, size = 25, normalized size = 1.04 \[ \frac {1}{12} \, b \cos \left (3 \, x\right ) - \frac {3}{4} \, b \cos \relax (x) - \frac {1}{12} \, a \sin \left (3 \, x\right ) + \frac {1}{4} \, a \sin \relax (x) \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="giac")

[Out]

1/12*b*cos(3*x) - 3/4*b*cos(x) - 1/12*a*sin(3*x) + 1/4*a*sin(x)

________________________________________________________________________________________

maple [A]  time = 0.82, size = 20, normalized size = 0.83 \[ -\frac {b \left (2+\sin ^{2}\relax (x )\right ) \cos \relax (x )}{3}+\frac {a \left (\sin ^{3}\relax (x )\right )}{3} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(x)^2*(a*cos(x)+b*sin(x)),x)

[Out]

-1/3*b*(2+sin(x)^2)*cos(x)+1/3*a*sin(x)^3

________________________________________________________________________________________

maxima [A]  time = 0.32, size = 20, normalized size = 0.83 \[ \frac {1}{3} \, a \sin \relax (x)^{3} + \frac {1}{3} \, {\left (\cos \relax (x)^{3} - 3 \, \cos \relax (x)\right )} b \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)^2*(a*cos(x)+b*sin(x)),x, algorithm="maxima")

[Out]

1/3*a*sin(x)^3 + 1/3*(cos(x)^3 - 3*cos(x))*b

________________________________________________________________________________________

mupad [B]  time = 0.45, size = 32, normalized size = 1.33 \[ -\frac {4\,\left (-2\,a\,{\mathrm {tan}\left (\frac {x}{2}\right )}^3+3\,b\,{\mathrm {tan}\left (\frac {x}{2}\right )}^2+b\right )}{3\,{\left ({\mathrm {tan}\left (\frac {x}{2}\right )}^2+1\right )}^3} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

int(sin(x)^2*(a*cos(x) + b*sin(x)),x)

[Out]

-(4*(b - 2*a*tan(x/2)^3 + 3*b*tan(x/2)^2))/(3*(tan(x/2)^2 + 1)^3)

________________________________________________________________________________________

sympy [A]  time = 0.28, size = 27, normalized size = 1.12 \[ \frac {a \sin ^{3}{\relax (x )}}{3} - b \sin ^{2}{\relax (x )} \cos {\relax (x )} - \frac {2 b \cos ^{3}{\relax (x )}}{3} \]

Verification of antiderivative is not currently implemented for this CAS.

[In]

integrate(sin(x)**2*(a*cos(x)+b*sin(x)),x)

[Out]

a*sin(x)**3/3 - b*sin(x)**2*cos(x) - 2*b*cos(x)**3/3

________________________________________________________________________________________